package top.moonkit.rs_pro.common;

import top.moonkit.rs_pro.utils.Mu;

/**
 * 统一响应结果封装类
 */
public class Result<T> {
    private boolean success;
    private String message;
    private T data;

    public Result() {}

    public Result(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> success(T data) {
        String message = Mu.m("success");
        return new Result<>(true, message, data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(true, message, data);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<>(false, message, null);
    }

    public static <T> Result<T> failData( T data) {
        String message = Mu.m("fail");
        return new Result<>(false, message, data);
    }

    public static <T> Result<T> fail(String message, T data) {
        return new Result<>(false, message, data);
    }

    // Getters and Setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}